package demo10;

import demo8.ArrayQueue;

import java.util.ArrayDeque;
import java.util.Stack;

//两个队列模拟实现栈
public class StackQueue1 {
    public Stack<Integer> qu1;
    public Stack<Integer> qu2;
    public StackQueue1(){
        qu1=new Stack<>();
        qu2=new Stack<>();
    }
    //入栈
    public void push(int val){
       qu1.push(val);
    }
    //出栈
    public int pop(){
        if(empty()){
            throw new RuntimeException("栈为空！！！");
        }
        if(qu2.isEmpty()){
            while(!qu1.isEmpty()){
                qu2.push(qu1.pop());
            }

        }
        return qu2.pop();
    }
    //判两个队列都空
    public boolean empty(){
        return qu1.isEmpty()&&qu2.isEmpty();
    }

}
